#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

#FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
FROM netcoresdk:3.1-buster-slim AS build
WORKDIR /src
COPY ["Sample/Sample.csproj", "Sample/"]
COPY ["Common.NPOI/Common.NPOI.csproj", "Common.NPOI/"]
COPY ["Common.RabbitMQ/Common.RabbitMQ.csproj", "Common.RabbitMQ/"]
COPY ["Common.MQ/Common.MQ.csproj", "Common.MQ/"]
COPY ["Common.Json/Common.Json.csproj", "Common.Json/"]
COPY ["Common.DataAnnotations/Common.DataAnnotations.csproj", "Common.DataAnnotations/"]
COPY ["Common/Common.csproj", "Common/"]
COPY ["Common.Swagger/Common.Swagger.csproj", "Common.Swagger/"]
COPY ["Common.Web/Common.Web.csproj", "Common.Web/"]
COPY ["Common.Logger/Common.Logger.csproj", "Common.Logger/"]
COPY ["MSATracert/MSATracert.csproj", "MSATracert/"]
COPY ["Common.Cache/Common.Cache.csproj", "Common.Cache/"]
COPY ["Common.Encrypt/Common.Encrypt.csproj", "Common.Encrypt/"]
COPY ["Common.Kafka/Common.Kafka.csproj", "Common.Kafka/"]
RUN dotnet restore "Sample/Sample.csproj"
COPY . .
WORKDIR "/src/Sample"
RUN dotnet build "Sample.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Sample.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Sample.dll"]

ENV AppName=Infrastructure-Sample
ENV AppId=15134553133810688
ENV AppSecret=56DF92F5082E31DCD145A48F4B65D049
ENV Env=local